home *** CD-ROM | disk | FTP | other *** search
Wrap
class LevelEditor { var mcRef; var aPlayObjects; var aRotateObjects; var aRotatingObjects; var bMoving; var oLevel; var oPanMachine; var bBoxUsingFeather; var nCurrentBoxNumber; static var oCtrl; static var LETTERS = ["A","B","C","D","E","F","G","H","I","J"]; static var PANELS = ["Amb_LE_mcGamePanel01","Amb_LE_mcGamePanel02","Amb_LE_mcGamePanel03","Amb_LE_mcGamePanel04","Amb_LE_mcGamePanel05","Amb_LE_mcGamePanel06","Amb_LE_mcGamePanel07","Amb_LE_mcGamePanel08","Amb_LE_mcGamePanel09","Amb_LE_mcGamePanel10"]; static var SUFFIX_FEATHER = "_F"; static var SUFFIX_MOONSTONES = "_MS"; static var PANELS_QTY = 25; static var MIN_SECONDS = 180; static var MAX_MINUTES = 15; static var MIN_MOONSTONES = 5; static var MAX_MOONSTONES = 100; function LevelEditor(__mcRef, __bEditLevel, __oLevelToEdit, __nNewLevelTargetRow) { this.mcRef = __mcRef; LevelEditor.oCtrl = this; this.aPlayObjects = new Array(); this.aRotateObjects = new Array(); this.aRotatingObjects = new Array(); this.bMoving = false; if(__bEditLevel) { this.oLevel = __oLevelToEdit; } else { this.oLevel = new BaseLevelData(); this.oLevel.LevelNumber = __nNewLevelTargetRow; this.oLevel.LevelType = BaseLevelData.LEVEL_TYPE_USER; this.oLevel.sPanelBg1 = "Amb_LE_mcBgPanel1"; this.oLevel.aPanelBg2.push("Amb_LE_mcBgPanel2_A"); this.oLevel.aPanelBg2.push("Amb_LE_mcBgPanel2_B"); this.oLevel.aPanelBg2.push("Amb_LE_mcBgPanel2_C"); this.oLevel.RequiredMS = 25; this.oLevel.TimeAllowed = 300000; this.oLevel.nFloorHeight = 345; this.oLevel.sPanelStart = "Amb_LE_mcGamePanel_Start"; this.oLevel.sPanelEnd = "Amb_LE_mcGamePanel_End"; var _loc3_ = 1; while(_loc3_ <= LevelEditor.PANELS_QTY) { var _loc4_ = LevelEditor.PANELS[Library.Utils.MoreMath.getRandomRange(0,LevelEditor.PANELS.length - 1)]; var _loc2_ = undefined; if(Math.random() < 0.5) { _loc2_ = LevelEditor.SUFFIX_FEATHER; } else { _loc2_ = LevelEditor.SUFFIX_MOONSTONES; } var _loc5_ = _loc4_ + _loc2_; this.oLevel.Panels.push(_loc5_); _loc3_ = _loc3_ + 1; } Game.Instance.Status.doAddUserLevel(this.oLevel); } this.doInit(); this.doSetUpMachine(); Main.Instance.doAddListener(this); } static function get Instance() { return LevelEditor.oCtrl; } function doHelpPage(__nPage) { this.mcRef.mcHelp.gotoAndStop(__nPage); } function doShowHelp() { this.mcRef.mcHelp._visible = true; this.doHelpPage(1); } function doHideHelp() { this.mcRef.mcHelp._visible = false; } function onMoveStartFor(__mcHit) { for(var _loc3_ in this.aPlayObjects) { if(this.aPlayObjects[_loc3_].hitTest(__mcHit)) { this.aPlayObjects[_loc3_].play(); } } for(_loc3_ in this.aRotateObjects) { if(this.aRotateObjects[_loc3_].hitTest(__mcHit)) { this.aRotatingObjects.push(this.aRotateObjects[_loc3_]); } } this.bMoving = true; } function onMoveStop() { for(var _loc2_ in this.aPlayObjects) { this.aPlayObjects[_loc2_].stop(); } this.aRotatingObjects = new Array(); this.bMoving = false; } function doAddPlayObject(__mcObj) { this.aPlayObjects.push(__mcObj); __mcObj.stop(); } function doAddRotateObject(__mcObj) { this.aRotateObjects.push(__mcObj); } function doEnterFrame() { if(this.bMoving) { for(var _loc2_ in this.aRotatingObjects) { this.aRotatingObjects[_loc2_]._rotation += 10; } } } function doBuzzerSound() { Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"Buzzer.mp3",100,1,true); } function doSecondsChange(__nChange) { this.oLevel.TimeAllowed += __nChange * 1000; if(this.oLevel.TimeAllowed > LevelEditor.MAX_MINUTES * 60 * 1000) { this.oLevel.TimeAllowed = LevelEditor.MAX_MINUTES * 60 * 1000; this.doBuzzerSound(); } else if(this.oLevel.TimeAllowed < LevelEditor.MIN_SECONDS * 1000) { this.oLevel.TimeAllowed = LevelEditor.MIN_SECONDS * 1000; this.doBuzzerSound(); } this.oLevel.Completed = false; this.doUpdateTimeNumber(); } function doMinutesChange(__nChange) { this.oLevel.TimeAllowed += __nChange * 60 * 1000; if(this.oLevel.TimeAllowed > LevelEditor.MAX_MINUTES * 60 * 1000) { this.oLevel.TimeAllowed = LevelEditor.MAX_MINUTES * 60 * 1000; this.doBuzzerSound(); } else if(this.oLevel.TimeAllowed < LevelEditor.MIN_SECONDS * 1000) { this.oLevel.TimeAllowed = LevelEditor.MIN_SECONDS * 1000; this.doBuzzerSound(); } this.oLevel.Completed = false; this.doUpdateTimeNumber(); } function doMoonStonesChange(__nChange) { this.oLevel.RequiredMS += __nChange; if(this.oLevel.RequiredMS > LevelEditor.MAX_MOONSTONES) { this.oLevel.RequiredMS = LevelEditor.MAX_MOONSTONES; this.doBuzzerSound(); } else if(this.oLevel.RequiredMS < LevelEditor.MIN_MOONSTONES) { this.oLevel.RequiredMS = LevelEditor.MIN_MOONSTONES; this.doBuzzerSound(); } this.oLevel.Completed = false; this.doUpdateMoonStonesNumber(); } function doTestLevel() { this.oLevel.doSave(); Game.Instance.doTestLevel(this.oLevel); } function doExitEditor() { this.oLevel.doSave(); Game.Instance.doExitEditor(); } function onLevelNameChange() { this.oLevel.LevelName = this.mcRef.txtLevelName.text; } function onToggleFeather() { if(this.oPanMachine.CurrentState == "Idle") { if(this.oPanMachine.CenterMachine.CurrentState == "Idle") { this.bBoxUsingFeather = !this.bBoxUsingFeather; var _loc3_ = this.getNumberForPanel(this.oLevel.Panels[this.nCurrentBoxNumber - 1]); var _loc2_ = LevelEditor.SUFFIX_MOONSTONES; if(this.bBoxUsingFeather) { _loc2_ = LevelEditor.SUFFIX_FEATHER; } this.oLevel.Panels[this.nCurrentBoxNumber - 1] = LevelEditor.PANELS[_loc3_] + _loc2_; this.oLevel.Completed = false; this.doUpdateFeatherCheck(); } } } function onScrollPanels(__nMove) { if(this.oPanMachine.CurrentState == "Idle") { if(this.oPanMachine.CenterMachine.CurrentState == "Idle") { var _loc3_ = this.getNumberForPanel(this.oLevel.Panels[this.nCurrentBoxNumber - 1]); var _loc2_ = _loc3_ + __nMove; if(_loc2_ < 0) { _loc2_ = LevelEditor.PANELS.length - 1; } if(_loc2_ > LevelEditor.PANELS.length - 1) { _loc2_ = 0; } this.oLevel.Panels[this.nCurrentBoxNumber - 1] = LevelEditor.PANELS[_loc2_] + this.getCurrentSuffix(); if(__nMove == 1) { this.oPanMachine.CenterMachine.doScrollUp(); this.onMoveStartFor(this.mcRef.mcZone2); Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"EditorMove1.mp3",100,1,true); } else { this.oPanMachine.CenterMachine.doScrollDown(); this.onMoveStartFor(this.mcRef.mcZone1); Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"EditorMove1.mp3",100,1,true); } this.oLevel.Completed = false; } } } function onScrollSide(__nMove) { if(this.oPanMachine.CurrentState == "Idle") { var _loc2_ = this.nCurrentBoxNumber + __nMove; if(_loc2_ < 1) { _loc2_ = LevelEditor.PANELS_QTY; } if(_loc2_ > LevelEditor.PANELS_QTY) { _loc2_ = 1; } this.nCurrentBoxNumber = _loc2_; this.doUpdateFeatherCheck(); if(__nMove == 1) { this.oPanMachine.doScrollToLeft(); this.onMoveStartFor(this.mcRef.mcZone4); Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"EditorMove2.mp3",100,1,true); } else { this.oPanMachine.doScrollToRight(); this.onMoveStartFor(this.mcRef.mcZone3); Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"EditorMove2.mp3",100,1,true); } } this.mcRef.txtQtyCur.text = Library.Utils.Tools.getFormatedNumber(this.nCurrentBoxNumber,2); this.mcRef.txtQtyAll.text = Library.Utils.Tools.getFormatedNumber(LevelEditor.PANELS_QTY,2); } function getPanelLinkage(__nPanelNumber) { return LevelEditor.PANELS[__nPanelNumber]; } function getLinkageFor(__nPanelNumber) { return this.oLevel.Panels[__nPanelNumber - 1]; } function getCurrentSuffix() { var _loc2_ = this.oLevel.Panels[this.nCurrentBoxNumber - 1]; var _loc4_ = undefined; var _loc3_ = _loc2_.lastIndexOf("_"); _loc4_ = _loc2_.substring(_loc3_); return _loc4_; } function getNumberForPanel(__sExtendedName) { var _loc2_ = undefined; var _loc1_ = 0; while(_loc1_ <= LevelEditor.PANELS.length - 1) { if(__sExtendedName.indexOf(LevelEditor.PANELS[_loc1_]) != -1) { _loc2_ = _loc1_; _loc1_ = LevelEditor.PANELS.length; } _loc1_ = _loc1_ + 1; } return _loc2_; } function doRefreshVisual() { this.oPanMachine.doRefreshVisual(); } function doDestroy() { } function get CurrentPanelNumber() { return this.nCurrentBoxNumber; } function doSetUpMachine() { this.oPanMachine = new EditorPanMachine(this.mcRef.mcMachine); this.mcRef.btnHelp.onRelease = Library.Utils.Delegate.create(this,this.doShowHelp); this.mcRef.btnLeft.onRelease = Library.Utils.Delegate.create(this,this.onScrollSide,-1); this.mcRef.btnRight.onRelease = Library.Utils.Delegate.create(this,this.onScrollSide,1); this.mcRef.btnUp.onRelease = Library.Utils.Delegate.create(this,this.onScrollPanels,-1); this.mcRef.btnDown.onRelease = Library.Utils.Delegate.create(this,this.onScrollPanels,1); this.doUpdateFeatherCheck(); this.mcRef.mcHelp._visible = false; this.mcRef.mcHelp.stop(); this.mcRef.mcHelp.btnExit.onRelease = Library.Utils.Delegate.create(this,this.doHideHelp); this.mcRef.mcHelp.btnBlock.useHandCursor = false; this.mcRef.mcHelp.btnHelp1.onRollOver = Library.Utils.Delegate.create(this,this.doHelpPage,4); this.mcRef.mcHelp.btnHelp2.onRollOver = Library.Utils.Delegate.create(this,this.doHelpPage,9); this.mcRef.mcHelp.btnHelp3.onRollOver = Library.Utils.Delegate.create(this,this.doHelpPage,3); this.mcRef.mcHelp.btnHelp4.onRollOver = Library.Utils.Delegate.create(this,this.doHelpPage,8); this.mcRef.mcHelp.btnHelp5.onRollOver = Library.Utils.Delegate.create(this,this.doHelpPage,7); this.mcRef.mcHelp.btnHelp6.onRollOver = Library.Utils.Delegate.create(this,this.doHelpPage,5); this.mcRef.mcHelp.btnHelp7.onRollOver = Library.Utils.Delegate.create(this,this.doHelpPage,2); this.mcRef.mcHelp.btnHelp8.onRollOver = Library.Utils.Delegate.create(this,this.doHelpPage,6); this.mcRef.mcHelp.btnHelp1.onRollOut = Library.Utils.Delegate.create(this,this.doHelpPage,1); this.mcRef.mcHelp.btnHelp2.onRollOut = Library.Utils.Delegate.create(this,this.doHelpPage,1); this.mcRef.mcHelp.btnHelp3.onRollOut = Library.Utils.Delegate.create(this,this.doHelpPage,1); this.mcRef.mcHelp.btnHelp4.onRollOut = Library.Utils.Delegate.create(this,this.doHelpPage,1); this.mcRef.mcHelp.btnHelp5.onRollOut = Library.Utils.Delegate.create(this,this.doHelpPage,1); this.mcRef.mcHelp.btnHelp6.onRollOut = Library.Utils.Delegate.create(this,this.doHelpPage,1); this.mcRef.mcHelp.btnHelp7.onRollOut = Library.Utils.Delegate.create(this,this.doHelpPage,1); this.mcRef.mcHelp.btnHelp8.onRollOut = Library.Utils.Delegate.create(this,this.doHelpPage,1); } function doInit() { this.nCurrentBoxNumber = 1; this.mcRef.txtQtyCur.text = Library.Utils.Tools.getFormatedNumber(this.nCurrentBoxNumber,2); this.mcRef.txtQtyAll.text = Library.Utils.Tools.getFormatedNumber(LevelEditor.PANELS_QTY,2); this.mcRef.btnQuitEditor.onRelease = Library.Utils.Delegate.create(this,this.doExitEditor); this.mcRef.btnTest.onRelease = Library.Utils.Delegate.create(this,this.doTestLevel); this.mcRef.txtLevelName.text = this.oLevel.LevelName; this.mcRef.txtLevelName.restrict = "a-z A-Z 0-9 _"; this.mcRef.txtLevelName.onChanged = Library.Utils.Delegate.create(this,this.onLevelNameChange); this.doUpdateFeatherCheck(); this.doUpdateMoonStonesNumber(); this.doUpdateTimeNumber(); } function doUpdateFeatherCheck() { var _loc2_ = undefined; if(this.getCurrentSuffix() == LevelEditor.SUFFIX_FEATHER) { this.bBoxUsingFeather = true; _loc2_ = "On"; } else { this.bBoxUsingFeather = false; _loc2_ = "Off"; } this.mcRef.mcFeatherCheckBox.gotoAndStop(_loc2_); this.mcRef.mcFeatherCheckBox.btnToggle.onRelease = Library.Utils.Delegate.create(this,this.onToggleFeather); this.doRefreshVisual(); } function doUpdateMoonStonesNumber() { this.mcRef.mcMoonStones.txtNumber.text = this.oLevel.RequiredMS; this.mcRef.mcMoonStones.btnHaut.onRelease = Library.Utils.Delegate.create(this,this.doMoonStonesChange,5); this.mcRef.mcMoonStones.btnBas.onRelease = Library.Utils.Delegate.create(this,this.doMoonStonesChange,-5); } function doUpdateTimeNumber() { var _loc2_ = this.oLevel.TimeAllowed / 1000 / 60; _loc2_ = Math.floor(_loc2_); var _loc3_ = undefined; if(_loc2_ > 0) { _loc3_ = this.oLevel.TimeAllowed / 1000 % (_loc2_ * 60); } else { _loc3_ = this.oLevel.TimeAllowed / 1000; } _loc3_ = Math.floor(_loc3_); this.mcRef.mcMinutes.txtNumber.text = _loc2_; this.mcRef.mcSeconds.txtNumber.text = Library.Utils.Tools.getFormatedNumber(_loc3_,2); this.mcRef.mcMinutes.btnHaut.onRelease = Library.Utils.Delegate.create(this,this.doMinutesChange,1); this.mcRef.mcMinutes.btnBas.onRelease = Library.Utils.Delegate.create(this,this.doMinutesChange,-1); this.mcRef.mcSeconds.btnHaut.onRelease = Library.Utils.Delegate.create(this,this.doSecondsChange,5); this.mcRef.mcSeconds.btnBas.onRelease = Library.Utils.Delegate.create(this,this.doSecondsChange,-5); } }